package com.training.java.core.collections.TreeSet;

//The purpose of this demo is that cars are added using tree set and order them by ascending order of make of the car.
import java.util.Set;
import java.util.TreeSet;

public class CarTreeSetDemo {

	public static void main(String[] args) {

		Car Ford = new Car("Ford", "Focus", 2013, 15000);
		Car Honda = new Car("Honda", "Accord", 2014, 23000);
		Car Ford2 = new Car("Ford", "Focus", 2013, 15000);
		Car Benz = new Car("Benz", "E250", 2015, 65000);
		Car Benz2 = new Car("Benz", "E250", 2015, 65000);

		Set<Car> cars = new TreeSet<Car>();

		cars.add(Ford);
		cars.add(Ford2);
		cars.add(Honda);
		cars.add(Benz);
		cars.add(Benz2);

		for (Car aCar : cars) {

			System.out.println("Make of the car = " + aCar.getMake());
			System.out.println("Model of the car = " + aCar.getModel());
			System.out.println("Year of the car = " + aCar.getYear());

		}

	}

}
